/*
 * collect_data.h
 *
 *  Created on: 2023年7月14日
 *      Author: 86176
 */

#ifndef COLLECT_DATA_H_
#define COLLECT_DATA_H_

#include <stdio.h>
#include <stdint.h>
#include "cJSON.h"



#define WELD_CLASS_SIZE   			20+5
#define WELD_WAY_SIZE   			20+5
#define WELD_POLARITY_SIZE   		20+5
#define WELD_ANGLE_SIZE   			20+5
#define WELD_DIRECTION_SIZE   		20+5
#define WELD_PARTY_SIZE   			20+5


#define WELD_DEVICE_ID_SIZE         12+5//预留空字符 避免占用
#define WELD_ID_SIZE                25+5
#define WELD_PERSON_ID_SIZE         20+5
#define WELD_LAYER_SIZE             2+5
#define WELD_LAYER_TEMP_SIZE        4+5

#define TIME_SIZE          30+5


typedef enum _collect_event_num
{
  //作业环境数据
  h_update_idle = 					0U,
  h_update_weldclass = 				1U,
  h_update_weldway = 				2U,
  h_update_weldpolarity = 			3U,
  h_update_weldangle = 				4U,
  h_update_welddirection = 			5U,
  h_update_weldparty = 				6U,
  //施焊前数据
  h_update_welddeviceid = 			7U,
  h_update_weldid = 				8U,
  h_update_weldpersonid = 			9U,
  h_update_weldlayer = 				10U,
  h_update_weldlayertemperature = 	11U,
  //作业环境数据
  h_update_envtemperature = 		12U,
  h_update_envhumidness = 			13U,
  h_update_envwindspeed = 			14U,
  //工况数据
  h_update_weldvoltage = 			15U,
  h_update_weldcurrent = 			16U,
  h_update_weldwirespeed = 			17U,
  h_update_weldspeed = 				18U,
  h_update_weldheatenergy = 		19U,
  h_update_protectiongasspeed = 	20U,
  //时间
  h_update_weld_collect_time = 		21U
} collect_event_num;

typedef struct _collect_data
{
	char weld_class[WELD_CLASS_SIZE];//焊机类型
	char weld_way[WELD_WAY_SIZE];//焊接方法
	char weld_polarity[WELD_POLARITY_SIZE];//焊接极性
	char weld_angle[WELD_ANGLE_SIZE];//焊接角度
	char weld_direction[WELD_ANGLE_SIZE];//焊接方向
	char weld_party[WELD_PARTY_SIZE];//焊接机组

	char weld_device_id[WELD_DEVICE_ID_SIZE];//设备编号
	char weld_id[WELD_ID_SIZE];//焊口编号
	char weld_person_id[WELD_PERSON_ID_SIZE];//人员编号
	char weld_layer[WELD_LAYER_SIZE];//焊层
	char weld_layer_temperature[WELD_LAYER_TEMP_SIZE];//层间温度


	uint32_t env_temperature;//施焊温度
	uint32_t env_humidness;//施焊湿度
	uint32_t env_wind_speed;//施焊风速

	uint32_t weld_voltage;//电压
	uint32_t weld_current;//电流
	uint32_t weld_wire_speed;//送丝速度
	uint32_t weld_speed;//焊接速度

	//目前未采集
	uint32_t weld_heat_energy;//热输入
	uint32_t protection_gas_speed;//保护气体流量

	char  weld_collect_time[TIME_SIZE];//采集时间
}collect_data;


//读取数据
//更新数据
//初始化
void init_collect_data(collect_data * data);
void update_collect_data(collect_data * data,collect_event_num event,char * userdata ,uint32_t usernum);
void insect_file_data(collect_data * data,char * buffer);

char* insect_mqtt_data_json(collect_data * data);
#endif /* COLLECT_DATA_H_ */
